<nz-spin *ngIf="isLoading" class="modal-spin"></nz-spin>
<form nz-form *ngIf="!isLoading" [formGroup]="validateForm" (ngSubmit)="submitForm()">
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="serviceStatus">联系结果</nz-form-label>
    <nz-form-control [nzSpan]="20" [nzValidateStatus]="validateForm.controls['serviceStatus']">
      <nz-select formControlName="serviceStatus" [nzPlaceHolder]="'联系结果'">
        <nz-option
          *ngFor="let option of cakeOrderServiceStatusOption"
          [nzLabel]="option.value"
          [nzValue]="option.key">
        </nz-option>
      </nz-select>
      `
      <nz-form-explain *ngIf="validateForm.get('serviceStatus').dirty && validateForm.get('serviceStatus').hasError('required')">请选联系结果</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="productId">产品名称</nz-form-label>
    <nz-form-control [nzSpan]="20">
      <nz-select formControlName="productId" [nzPlaceHolder]="'关联产品'" nzDisabled>
        <nz-option
          *ngFor="let option of allProducts"
          [nzLabel]="option.title"
          [nzValue]="option.id">
        </nz-option>
      </nz-select>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="goodsQuantity">预定数量</nz-form-label>
    <nz-form-control [nzSpan]="20">
      <nz-input-number style="width: 100%;" [nzMin]="1" [nzMax]="9000000" [nzStep]="1" [nzPrecision]="2" [nzPlaceHolder]="'预定数量'" formControlName="goodsQuantity" (ngModelChange)="countTotalPrice($event,'goodsQuantity')"></nz-input-number>
      <nz-form-explain *ngIf="validateForm.get('goodsQuantity').dirty && validateForm.get('goodsQuantity').hasError('required')">请输入预定数量</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="goodsUnitPrice">单价({{entity.productId|dicsNamePipe:allProducts:"id":"unit"}})</nz-form-label>
    <nz-form-control [nzSpan]="20">
      <nz-input-number style="width: 100%;" [nzMin]="1" [nzMax]="9000000" [nzStep]="1" [nzPrecision]="2" [nzPlaceHolder]="'预定单价(盒)'" formControlName="goodsUnitPrice"  (ngModelChange)="countTotalPrice($event,'goodsUnitPrice')"></nz-input-number>
      <nz-form-explain *ngIf="validateForm.get('goodsUnitPrice').dirty && validateForm.get('goodsUnitPrice').hasError('required')">请输入单价(盒)</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="goodsTotalPrice">总价</nz-form-label>
    <nz-form-control [nzSpan]="20">
      <nz-input-number style="width: 100%;" [nzMin]="1" [nzMax]="9000000" [nzStep]="1" [nzPrecision]="2" [nzPlaceHolder]="'预定总价'" formControlName="goodsTotalPrice"></nz-input-number>
      <nz-form-explain *ngIf="validateForm.get('goodsTotalPrice').dirty && validateForm.get('goodsTotalPrice').hasError('required')">请输入总价</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="4" nzRequired nzFor="remark">备注</nz-form-label>
    <nz-form-control [nzSpan]="20" [nzValidateStatus]="validateForm.controls['remark']">
      <textarea rows="5" nz-input formControlName="remark" placeholder="备注"></textarea>
      <nz-form-explain *ngIf="validateForm.get('remark').dirty && validateForm.get('remark').hasError('required')">请输入备注</nz-form-explain>
      <nz-form-explain *ngIf="validateForm.get('remark').dirty && validateForm.get('remark').hasError('maxlength')">不能超过200个字</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <div class="modal-footer">
    <button nz-button type="button" (click)="close()">关闭</button>
    <button nz-button type="submit" [nzType]="'primary'" *ngIf="entity.serviceStatus != 2" >保存</button>
  </div>
</form>
